// 用户详情页面逻辑
Page({
  data: {
    userInfo: {
      id: 1,
      name: "西瓜",
      avatar: "https://images.unsplash.com/photo-1494790108755-2616b612b786?w=120&h=120&fit=crop&crop=face",
      gender: "女",
      joinYear: "2021",
      recipeCount: 15,
      followerCount: 1234,
      followingCount: 56
    },
    userRecipes: [
      {
        id: 1,
        title: "空气炸锅版肥牛卷,简单易做,快@你的闺蜜做起来~",
        image: "https://images.unsplash.com/photo-1546833999-b9f581a1996f?w=300&h=200&fit=crop",
        time: "20-30分钟",
        difficulty: "零厨艺"
      },
      {
        id: 2,
        title: "轻食减脂谷物饭",
        image: "https://images.unsplash.com/photo-1512621776951-a57141f2eefd?w=300&h=200&fit=crop",
        time: "10-15分钟",
        difficulty: "零厨艺"
      },
      {
        id: 3,
        title: "黑森林巧克力蛋糕",
        image: "https://images.unsplash.com/photo-1578985545062-69928b1d9587?w=300&h=200&fit=crop",
        time: "10-15分钟",
        difficulty: "零厨艺"
      },
      {
        id: 4,
        title: "香煎三文鱼配时蔬",
        image: "https://images.unsplash.com/photo-1467003909585-2f8a72700288?w=300&h=200&fit=crop",
        time: "15-20分钟",
        difficulty: "初级"
      }
    ]
  },

  onLoad: function(options) {
    // 获取用户ID
    const userId = options.id;
    this.loadUserData(userId);
  },

  // 加载用户数据
  loadUserData: function(userId) {
    // TODO: 调用后端API获取用户数据
    // 示例：
    // wx.request({
    //   url: 'https://api.example.com/user/' + userId,
    //   success: (res) => {
    //     this.setData({
    //       userInfo: res.data.userInfo,
    //       userRecipes: res.data.recipes
    //     });
    //   }
    // });
    
    console.log('加载用户数据:', userId);
  },

  // 点击食谱卡片
  onRecipeTap: function(e) {
    const recipeId = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/index/pages/recipe/recipe?id=' + recipeId
    });
  }
}); 